import { Component, Node } from "cc";
import { IObjectItem } from "../ObjectPool/ObjectPool";
import NodeMap from "../NodeMap";

export default class EntityBase extends Component implements IObjectItem{
    isActive: boolean = false;

    /**
     * 继承自IObjectItem 进入对象池时初始化数据。应该是在onInit之后调用
     * @param param 实体数据
     */
    public InitItem(param: any): void {
        
    }

    protected markedChild : NodeMap = new NodeMap();

    protected onLoad(): void {
        this.markedChild.SearchAllNode(this.node);
        this.onInit();
    }

    /**
     *  初始化调用
     */
    public onInit(){

    }

    public CloseSelf(): void{
        /**
         * 入池前把自己父节点去掉
         */
        this.node.removeFromParent();
        this.isActive = false;
    }
}